/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entity;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.Lob;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author adama
 */
@Entity
@Table(name = "personne")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Personne.findAll", query = "SELECT p FROM Personne p"),
    @NamedQuery(name = "Personne.findByIdPersonne", query = "SELECT p FROM Personne p WHERE p.idPersonne = :idPersonne"),
    @NamedQuery(name = "Personne.findByNom", query = "SELECT p FROM Personne p WHERE p.nom = :nom"),
    @NamedQuery(name = "Personne.findByPrenom", query = "SELECT p FROM Personne p WHERE p.prenom = :prenom"),
    @NamedQuery(name = "Personne.findByPseudo", query = "SELECT p FROM Personne p WHERE p.pseudo = :pseudo"),
    @NamedQuery(name = "Personne.findByEMail", query = "SELECT p FROM Personne p WHERE p.eMail = :eMail"),
    @NamedQuery(name = "Personne.findByNumTel", query = "SELECT p FROM Personne p WHERE p.numTel = :numTel"),
    @NamedQuery(name = "Personne.findByRole", query = "SELECT p FROM Personne p WHERE p.role = :role")})
public class Personne implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "idPersonne")
    private Integer idPersonne;
    @Basic(optional = false)
    @NotNull
    @Column(name = "Nom")
    private char nom;
    @Basic(optional = false)
    @NotNull
    @Column(name = "Prenom")
    private char prenom;
    @Column(name = "Pseudo")
    private Character pseudo;
    @Lob
    @Size(max = 65535)
    @Column(name = "Description")
    private String description;
    // @Pattern(regexp="[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?", message="Invalid email")//if the field contains email address consider using this annotation to enforce field validation
    @Size(max = 255)
    @Column(name = "EMail")
    private String eMail;
    @Size(max = 45)
    @Column(name = "NumTel")
    private String numTel;
    @Basic(optional = false)
    @NotNull
    @Lob
    @Column(name = "MotDePasse")
    private byte[] motDePasse;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 10)
    @Column(name = "Role")
    private String role;
    @Lob
    @Column(name = "Photo")
    private byte[] photo;
    @JoinTable(name = "relationsuivi", joinColumns = {
        @JoinColumn(name = "Key_IdUser", referencedColumnName = "idPersonne")}, inverseJoinColumns = {
        @JoinColumn(name = "Key_IdProducteur", referencedColumnName = "idPersonne")})
    @ManyToMany
    private Collection<Personne> personneCollection;
    @ManyToMany(mappedBy = "personneCollection")
    private Collection<Personne> personneCollection1;
    @OneToMany(mappedBy = "idProducteur")
    private Collection<Relationvideoartiste> relationvideoartisteCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idPersonne")
    private Collection<Playlist> playlistCollection;

    public Personne() {
    }

    public Personne(Integer idPersonne) {
        this.idPersonne = idPersonne;
    }

    public Personne(Integer idPersonne, char nom, char prenom, byte[] motDePasse, String role) {
        this.idPersonne = idPersonne;
        this.nom = nom;
        this.prenom = prenom;
        this.motDePasse = motDePasse;
        this.role = role;
    }

    public Integer getIdPersonne() {
        return idPersonne;
    }

    public void setIdPersonne(Integer idPersonne) {
        this.idPersonne = idPersonne;
    }

    public char getNom() {
        return nom;
    }

    public void setNom(char nom) {
        this.nom = nom;
    }

    public char getPrenom() {
        return prenom;
    }

    public void setPrenom(char prenom) {
        this.prenom = prenom;
    }

    public Character getPseudo() {
        return pseudo;
    }

    public void setPseudo(Character pseudo) {
        this.pseudo = pseudo;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getEMail() {
        return eMail;
    }

    public void setEMail(String eMail) {
        this.eMail = eMail;
    }

    public String getNumTel() {
        return numTel;
    }

    public void setNumTel(String numTel) {
        this.numTel = numTel;
    }

    public byte[] getMotDePasse() {
        return motDePasse;
    }

    public void setMotDePasse(byte[] motDePasse) {
        this.motDePasse = motDePasse;
    }

    public String getRole() {
        return role;
    }

    public void setRole(String role) {
        this.role = role;
    }

    public byte[] getPhoto() {
        return photo;
    }

    public void setPhoto(byte[] photo) {
        this.photo = photo;
    }

    @XmlTransient
    public Collection<Personne> getPersonneCollection() {
        return personneCollection;
    }

    public void setPersonneCollection(Collection<Personne> personneCollection) {
        this.personneCollection = personneCollection;
    }

    @XmlTransient
    public Collection<Personne> getPersonneCollection1() {
        return personneCollection1;
    }

    public void setPersonneCollection1(Collection<Personne> personneCollection1) {
        this.personneCollection1 = personneCollection1;
    }

    @XmlTransient
    public Collection<Relationvideoartiste> getRelationvideoartisteCollection() {
        return relationvideoartisteCollection;
    }

    public void setRelationvideoartisteCollection(Collection<Relationvideoartiste> relationvideoartisteCollection) {
        this.relationvideoartisteCollection = relationvideoartisteCollection;
    }

    @XmlTransient
    public Collection<Playlist> getPlaylistCollection() {
        return playlistCollection;
    }

    public void setPlaylistCollection(Collection<Playlist> playlistCollection) {
        this.playlistCollection = playlistCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idPersonne != null ? idPersonne.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Personne)) {
            return false;
        }
        Personne other = (Personne) object;
        if ((this.idPersonne == null && other.idPersonne != null) || (this.idPersonne != null && !this.idPersonne.equals(other.idPersonne))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entity.Personne[ idPersonne=" + idPersonne + " ]";
    }
    
}
